package com.class6.exception;
/**
 *
 * 测试数组中常见的异常
 *
 * @author 尚硅谷-宋红康
 * @create 13:22
 */
public class ArrayExceptionTest {
	public static void main(String[] args) {
		// 1. 数组角标越界的异常：
		int[] arr = new int[2];
//		ArrayIndexOutOfBoundsException
//		arr[2] = 10;
//		System.out.println(arr[2]);


		// 2. 空指针异常：
//		int[][] ints = new int[3][];
//		System.out.println(ints[0][0]);
//		String str = null;
//		NullPointerException
//		System.out.println(str.length());

		int[] arr1 = {1,2,3,4,5,6,7,8,9,10};
		int sum = 0;
		for (int i = 0; i < arr1.length; i++) {
			sum += arr1[i];
		}
		System.out.println(sum);



	}
}
